/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.webrx.example;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * <p>Project: javaseapp - Ex2
 * <p>Powered by webrx On 2021-07-28 09:48:04
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Ex2 {
    public static void main(String[] args) {
        //java.lang.String 有一个format() 方法，格式并返回字符串信息
        String s1 = String.format("%1$tF %1$tT", System.currentTimeMillis());
        System.out.println(s1);

        String s2 = String.format("#%02x%02x%02x", 255, 0, 0);
        System.out.println(s2);

        String s3 = String.format("%02d", 8);
        System.out.println(s3);
        String s4 = String.format("%.2f", 30.12348);
        System.out.println(s4);

        //格式化日期是 %tF %tT %tA %tr
        SimpleDateFormat abc = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date d = new Date();
        System.out.println(abc.format(d));
    }
}
